package com.mccrea.pattern.memento;

/**
 * @Classname Client
 * @Description 备忘录模式测试
 * @Date 2021/5/24 0024 14:02
 * @Created by Mccrea_Gao
 */
public class Client {
    public static void main(String[] args) {
        Originator originator = new Originator();
        Caretaker caretaker = new Caretaker();
        originator.setState("S0");
        System.out.println("初始状态： " + originator.getState());
        caretaker.setMemento(originator.createMemento());
        originator.setState("S1");
        System.out.println("新的状态： " + originator.getState());
        originator.restoreMemento(caretaker.getMemento());
        System.out.println("恢复状态： " + originator.getState());
    }
}
